/*
 *说明：我的权限信息 首页脚本
 *
 *@author mlc 2013-04-10
*/

var opeForm;
var grid;

$(function(){
	
	opeForm = $('#opeForm');

	grid=$('#listTable').datagrid({
		title: '明细列表',
		frozenColumns:[[
            {title:'选择',field:'ck',checkbox:true}
		]],
		columns:[[

            {title:'节点名称',field:'NODE_DECODE',align:'center',width:80},
            
            {title:'资源组',field:'RSC_GRP_NAME',align:'center',width:70},

            {title:'资源名称',field:'RSC_NAME',align:'center',width:70},

            {title:'账号',field:'RSC_ACC',align:'center',width:60},

            {title:'协议',field:'PRO_NAME',align:'center',width:60},

            {title:'端口',field:'PORT',align:'center',width:40},

            {title:'运维目的',field:'OPERATION_TYPE_DECODE',align:'center',width:80},

            {title:'开始时间',field:'START_TIME',align:'center',width:90},
            
            {title:'有效期(分钟)',field:'AVAILABLE_LENGTH',align:'center',width:40},
          
            {title:'策略名称',field:'CMD_POLICY_NAME',align:'center',width:80}
            
        ]],
		pagination:true,
		singleSelect: false,
		onDblClickRow: function(rowIndex, rowData) {
	    	window.returnValue = rowData;
	    	window.close();
	    }
		
	});

	queryOperation();

	$('#queryBtn').click(queryOperation);
	$('#clearBtn').click(clearOperation);
});



//翻页时自动调用此函数
function onLoadPrev(msg){
	var queryParams=grid.datagrid('options').queryParams;
	queryParams['firstQuery']=false;
}

//查询操作
function queryOperation(){
	var params = opeForm.serializeObject();
	grid.datagrid("options").pageNumber = 1;
	grid.datagrid({
		url: 'P_WF_ACL_APPLY!showUsrAuthRscList.do',
		queryParams: jQuery.extend({}, params, {'firstQuery': true})
	});
}

//清空操作（重置）
function clearOperation() {
	opeForm.resetForm();
}

//选择资源组
function select_c_rsc_grp() {
	var node_id = $('#node_id').val();
	var action = "C_RSC_GRP!showSelect.do?model.node_id=" + node_id;
	var row = showModalWin(action,'A2');
	
	if (row) {
		$('#rsc_grp_id').val(row.rsc_grp_id);
		$('#rsc_grp_name').val(row.rsc_grp_name);
	}
}

//操作成功后刷新列表
function afterOK(){
	queryOperation();
}